// 一级路由
import Login from '../mianjing/Login.vue'
import Register from '../mianjing/Register.vue'
import HomeCom from '../mianjing/HomeCom.vue'
import Detail from '../mianjing/Detail.vue'
//二级路由
import Home from '../mianjing/Sub/Home.vue'
import Collect from '../mianjing/Sub/Collect.vue'
import Love from '../mianjing/Sub/Love.vue'
import My from '../mianjing/Sub/My.vue'

import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter) // VueRouter插件初始化

// 创建了一个路由对象
const router = new VueRouter({
  // routes 路由规则们
  // route  一条路由规则 { path: 路径, component: 组件 }
  routes: [
    {
      path: '/login',
      name: 'Login',
      component: Login
    },
    {
      path: '/register',
      name: 'Register',
      component: Register
    },
    {
      path: '/detail/:id',
      name: 'detail',
      component: Detail
    },
    {
      // path: '/',
      // name: 'HomeCom',
      // component: HomeCom,
      // redirect:'/home',
      // children: [
      //   {
      //     path: '/home',
      //     name: '首页',
      //     component: Home
      //   },
      //   {
      //     path: '/collect',
      //     name: '收藏',
      //     component: Collect
      //   },
      //   {
      //     path: '/love',
      //     name: '喜欢',
      //     component: Love
      //   },
      //   {
      //     path: '/my',
      //     name: '我的',
      //     component: My
      //   },
      // ]

      //二级路由路径不写  /  写法
      path: '/homecom',
      name: 'HomeCom',
      redirect: '/homecom/home',
      component: HomeCom,

      children: [
        {
          path: 'home',
          name: '首页',
          component: Home,
          meta: {
            keepAlive: true
          },
        },
        {
          path: 'collect',
          name: '收藏',
          component: Collect
        },
        {
          path: 'love',
          name: '喜欢',
          component: Love
        },
        {
          path: 'my',
          name: '我的',
          component: My
        },
      ]
    }
  ]
})

export default router